//
//  HNSH_AccountSafeViewController.m
//  HNSH_SingleProject
//
//  Created by 李宇廷 on 2023/2/28.
//

#import "HNSH_AccountSafeViewController.h"

//view
#import "HNSH_AccountCell.h"

//vc
#import "HNSH_SafeHomeViewController.h"
#import "HNSH_CancellationViewController.h"

@interface HNSH_AccountSafeViewController ()

/* infoAry */
@property (nonatomic, strong) NSArray *infoAry;
@end

static NSString *HNSH_AccountCellID = @"HNSH_AccountCellID";

@implementation HNSH_AccountSafeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self showNavTitle:@"账户与安全" showLeftItem:YES];
    
    self.view.backgroundColor = [UIColor appWhiteLabelColor];
    
    [self configTableView];
}

- (void)configTableView {
    self.tableView.rowHeight = 44;
    [self.tableView registerClass:[HNSH_AccountCell class] forCellReuseIdentifier:HNSH_AccountCellID];
}

#pragma mark lazy
- (NSArray *)infoAry {
    if (!_infoAry) {
        _infoAry = @[@{@"title":@"手机号：",@"des":[[ST_UserManager shareInstance].user.phone isNotBlank] ? [ST_UserManager shareInstance].user.phone : @"未绑定"},
                     @{@"title":@"修改登录密码",@"des":@""},
                     @{@"title":@"修改支付密码",@"des":@""},
                     @{@"title":@"注销账号",@"des":@""}];
    }
    return _infoAry;
}

#pragma mark - delegate
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.infoAry.count;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return 0.01f;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    return 0.01f;
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
    return [UIView new];
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    return [UIView new];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    HNSH_AccountCell *cell = [tableView dequeueReusableCellWithIdentifier:HNSH_AccountCellID];
    cell.dict = self.infoAry[indexPath.row];
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    NSDictionary *dic = self.infoAry[indexPath.row];
    if ([dic[@"title"] isEqualToString:@"账户与安全"]) {
        
    } else if ([dic[@"title"] isEqualToString:@"修改登录密码"]) {
        HNSH_SafeHomeViewController *vc = [[HNSH_SafeHomeViewController alloc]init];
        vc.style = HNSH_SafeHomeStyle_ChangePassword;
        [self.navigationController pushViewController:vc animated:YES];
    } else if ([dic[@"title"] isEqualToString:@"修改支付密码"]) {
        HNSH_SafeHomeViewController *vc = [[HNSH_SafeHomeViewController alloc]init];
        vc.style = HNSH_SafeHomeStyle_ChangePay;
        [self.navigationController pushViewController:vc animated:YES];
    } else if ([dic[@"title"] isEqualToString:@"注销账号"]) {
        HNSH_CancellationViewController *vc = [[HNSH_CancellationViewController alloc]init];
        [self.navigationController pushViewController:vc animated:YES];
    }
}


@end
